package lu.med.praxiswahl.wahlumed.client.patienten;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JTextArea;

import lu.med.praxiswahl.wahlumed.client.utilities.Parser;
import lu.med.praxiswahl.wahlumed.client.wclient.Main;


/**
 * 
 * @author Lars Holger Roth
 */
@SuppressWarnings("serial")
public class BesonderheitenEdit extends JDialog implements ActionListener
{
    private PatientenPanel owner;
    private JTextArea input;

    public BesonderheitenEdit(PatientenPanel owner, Main win)
    {
	super(win, "Besonderheiten", true);
	this.owner = owner;
	this.setLayout(new BorderLayout());
	JPanel bPannel = new JPanel();
	input = new JTextArea(Parser.transformStringToBrackets(owner
		.getBesonderheiten()));
	if (input.getText().equals("null"))
	    input.setText("");
	this.add(input, BorderLayout.CENTER);
	JButton ok = new JButton("Ok");
	ok.addActionListener(this);
	JButton cancel = new JButton("Abbrechen");
	cancel.addActionListener(this);
	bPannel.add(ok);
	bPannel.add(cancel);
	this.add(bPannel, BorderLayout.SOUTH);
	this.pack();
	this.setLocation(500, 300);
	this.setVisible(true);
    }

    public void actionPerformed(ActionEvent e)
    {
	if (e.getActionCommand().equals("Ok"))
	{
	    owner.setBesonderheiten(Parser.transformStringOfBrackets(input
		    .getText()));
	    this.setVisible(false);
	}
	else
	{
	    this.setVisible(false);
	}
    }
}